package controller;

import java.awt.Desktop;
import java.awt.event.ActionEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.awt.event.ActionListener;
import view.GUISudokuOnline;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JFrame;


public class ControllerSudokuOnline extends JFrame implements ActionListener {
   
    
    private GUISudokuOnline ventana = new GUISudokuOnline();
    
   
    
    public void mostrarGUISudokuOnline(){
        ventana.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        String url = e.getActionCommand();
        if (url.equals("Sudoku Mania")){
            irURL("http://www.sudokumania.com.ar/");
        }    
        if (url.equals("Web Sudoku")){
            irURL("http://es.websudoku.com/");
        }
        if (url.equals("Sudoku Online")) {
            irURL("http://www.sudoku-online.org/");
        }
        if (url.equals("Desudoku")) {
            irURL("http://www.desudoku.com/");
        }
        if (url.equals("Sudokus-online")) {
            irURL("http://www.sudokus-online.com/");
        }
        
    }
    
    private void irURL(String url) {
        try {
            URI uri = new URI(url);
            Desktop desktop = null;
            
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
            
            if (desktop != null) {
                try {
                    desktop.browse(uri);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (URISyntaxException ex) {
            Logger.getLogger(ControllerSudokuOnline.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }


   
        
}
